package com.design.AdapterMode.demo;

import java.util.ArrayList;
import java.util.List;

/**
 * 敏感词过滤2
 */
public class Filter2 {

    private static final List<String> sensitiveWords = new ArrayList<>(3);

    static {
        sensitiveWords.add("傻逼");
        sensitiveWords.add("煞笔");
        sensitiveWords.add("艹");
    }

    public String filter(Word word, String replaceStr){
        if(null == word){
            return null;
        }
        sensitiveWords.forEach(v->{
            if(word.getWord().contains(v)){
                System.out.println("敏感词 ：" + v + ", 替换");
                word.getWord().replaceAll(v, replaceStr);
            }
        });
        return word.getWord();
    }

}
